import redis

class Re:
    def __init__(self):
        self.conn = redis.Redis(host='localhost',port=6379,db=1)

    def set_str(self,key,value,time=0):
        if time == 0:
            self.conn.set(key,value)
        else:
            self.conn.setex(key,value,time)

    def get_str(self,key):
        value = self.conn.get(key)
        if value:
            value = str(value,encoding='utf8')

        return value

    def del_str(self,key):
        self.conn.delete(key)

r = Re()